# encoding: utf-8
""" 
@version: v1.0 
@author: autumner 
@license: Apache Licence  
@contact: 18322313385@163.com 
@site:  https://gitee.com/autumner/pythoncookbook
@software: PyCharm 
@file: net_tcp_client.py 
@time: 2019/7/11 上午9:25
"""

'''
创建TCP的客户端
'''
from socket import socket, AF_INET, SOCK_STREAM


s = socket(AF_INET, SOCK_STREAM)
s.connect(('localhost', 20000))
s.send(b'hello')
print(s.recv(8192))
for i in range(100):
    s.send(b'hello world!')
    print(i,'次', s.recv(8192))
s.close()